package com.trump.baiduim.dao;

import com.trump.baiduim.model.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface UserDao {
    int deleteByPrimaryKey(Long userId);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Long userId);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    @Select("select * from user as u order by u.user_account")
    List<User> getAllUserInfo();
    
    User selectByUserAccount(String userAccount);
    
    User findUserByUserAccountAndPassword(@Param("userAccount") String userAccount, @Param("userPassword") String userPassword);


    @Select("SELECT * FROM user WHERE user_account=#{userAccount} AND user_password=#{password} AND role_code='0001000100010001' AND user_status!='00'")
    User getUserByAccountAndPassword(String userAccount, String password);
    
    @Delete("delete from user where user.user_account=#{userAccount}")
    void deleteUserInfoByUserAccount(String userAccount);

    void updateUserInfo(User user);
    
    List<User> fuzzySearch(@Param("departmentName") String departmentName, @Param("userName") String userName);

    void updateUserHeadPortrait(@Param("userAccount") String userAccount, @Param("userHeadPortrait") String userHeadPortrait, @Param("updateTime") Date updateTime);

    void updateUserStatus(String userAccount);
}